/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.tesoreria.bc;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.cip.esymons.tesoreria.be.Chequera;
import org.cip.esymons.tesoreria.be.CuentaBancaria;

/**
 *
 * @author Gilmar
 */
public class ChequeraDelegate {
    private final ChequeraFacadeLocal local;

    public ChequeraDelegate() {
        local = lookupChequeraFacade();
    }

    public void create(Chequera chequera){
        local.create(chequera);
    }

    public void edit(Chequera chequera){
        local.edit(chequera);
    }

    public void remove(Chequera chequera){
        local.remove(chequera);
    }

    public Chequera find(Object id){
        return local.find(id) ;
    }

    public List<Chequera> findAll(){
        return local.findAll();
    }

    public Object[] obtenerNumeracionActual(CuentaBancaria cuentaBancaria){
        return local.obtenerNumeracionActual(cuentaBancaria);
    }

    private ChequeraFacadeLocal lookupChequeraFacade() {
        try {
            Context c = new InitialContext();
            return (ChequeraFacadeLocal) c.lookup("java:comp/env/ChequeraFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

}
